/**
 * Created by abdulazizalonizi on 8/7/17.
 */
import java.util.Scanner ;
public class Task5 {
    public static void main(String [] args)
    {
        Scanner kb = new Scanner (System.in);
        int [][] arr2D = new int [4][4];
        System.out.println("fill 4*4 array row wise");
        for (int i = 0  ; i <arr2D.length ; i++)
        {

            for (int j =0 ; j <arr2D[i].length ; j++)
            {

                arr2D[i][j] = kb.nextInt();
            }

        }
        System.out.println ("enter columns you want to switch");
        int m = kb.nextInt();
        int n = kb.nextInt();
        printArr(arr2D);
        System.out.println(" ");
        System.out.println("Array after reversing columns :\n");
        printArr(swapCol(arr2D,m,n));



    }

    public static int[][] swapCol (int[][] arr2D , int m , int n)
    {
        if ( (m<0 & m>=arr2D[0].length) | (n<0 & n>=arr2D[0].length) )
        {
            throw new IllegalArgumentException("Error : invalid input");
        }

        int [][] arr2D_swap = new int [arr2D.length][arr2D[0].length];

        for (int i = 0 ; i <arr2D.length ; i++)
        {
            for (int j = 0 ; j<arr2D[i].length ;j++ )
            {
                arr2D_swap[i][j]=arr2D[i][j];
            }
           // System.out.println("");

        }




        for (int i = 0 ; i <arr2D.length;i++)
        {
            arr2D_swap[i][n]=arr2D[i][m];
            arr2D_swap[i][m] =arr2D[i][n];
        }
        return arr2D_swap;
    }

    public static void printArr(int[][] arr)
    {
        for (int i = 0 ; i <arr.length ; i++)
        {
            for (int j = 0 ; j<arr[i].length ;j++ )
            {
                System.out.print(arr[i][j] + " ");
            }
            System.out.println("");

        }

    }


}











//QWJkdWxheml6IEFsb25pemkgQ3JlYXRlZCB0aGlzIGNvZGUgLCBoZSB3b3JrZWQgdmVyeSBoYXJkIG9uIGl0ICwgRE8gTk9UIFVTRSBJVCBUTyBTVUJNSVQgWU9VUiBBU1NJR05NRU5UIA0K
//UTF_8